package oyl.selenium.excel;

import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;

import java.io.File;
import java.io.FileOutputStream;

/**
 * Created by Nicky.Tang on 2021/9/27 3:45 下午
 *
 * @since 02.12.10
 */
public class DoTest {
    public static void main(String[] args) throws Exception {
        //创建HSSFWorkbook对象
        XSSFWorkbook wb = new XSSFWorkbook();
        //创建HSSFSheet对象
        Sheet sheet = wb.createSheet("sheet0");
        //创建HSSFRow对象
        Row row = sheet.createRow(0);
        for (int i = 0; i < 300; i++) {
            Cell cell = row.createCell(i);
            if(i%2==0){
                //创建HSSFCell对象
                //设置单元格的值
                cell.setCellValue(i+2);
            }
        }
        //输出Excel文件
        String filePath = new File("").getAbsolutePath()+".src.main.java.oyl.selenium.excel".replaceAll("\\.","/");
        FileOutputStream output = new FileOutputStream(filePath+"/test.xlsx");
        wb.write(output);
        output.flush();
    }
}
